home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Presentations / Presentations ’92 / PatchWorks Kit / <PatchWorks++> / SetUpA5.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-01  |  1.1 KB  |  41 lines  |  [TEXT/KAHL]

  1.  
  2. /*
  3.  *  SetUpA5.h
  4.  *
  5.  *  Copyright (c) 1991 Symantec Corporation.  All rights reserved.
  6.  *
  7.  *  This defines "SetUpA5()" and "RestoreA5()" routines that will work
  8.  *  in all A5-based projects.
  9.  *
  10.  *  "RememberA5()" must be called in advance to
  11.  *  store away the value of A5 where it can be found by "SetUpA5()".
  12.  *  The matching calls to "RememberA5()" and
  13.  *  "SetUpA5()" *MUST* occur in the same file.
  14.  *
  15.  *  Note that "RememberA5()", "SetUpA5()", and
  16.  *  "RestoreA5()" are not external.  Each file that uses them must
  17.  *  include its own copy.
  18.  *
  19.  *  If this file is used in the main file of a code resource with
  20.  *  "Custom Headers", be sure to #include it *AFTER* the custom
  21.  *  header!  Otherwise, the code resource will begin with the code
  22.  *  for the function "__GetA5()", defined below.
  23.  *
  24.  */
  25.  
  26.  
  27. static void
  28. __GetA5(void)
  29. {
  30.     asm {
  31.         bsr.s    @1
  32.         dc.l    0            ;  store A5 here
  33. @1        move.l    (sp)+,a1
  34.     }
  35. }
  36.  
  37.  
  38. #define RememberA5()    do { __GetA5(); asm { move.l a5,(a1) } } while (0)
  39. #define SetUpA5()        do { asm { move.l a5,-(sp) } __GetA5(); asm { move.l (a1),a5 } } while (0)
  40. #define RestoreA5()        do { asm { move.l (sp)+,a5 } } while (0)
  41.